package com.newtouch.bxzs.enterprise.controller;

import com.newtouch.bxzs.common.base.response.BaseResponse;
import com.newtouch.bxzs.common.base.response.RespGenerator;
import com.newtouch.bxzs.enterprise.config.MyLog;
import com.newtouch.bxzs.enterprise.model.bo.BankCustomerAnalysisBO;
import com.newtouch.bxzs.enterprise.model.bo.InsuranceCustomerAnalysisBO;
import com.newtouch.bxzs.enterprise.model.bo.PersonalCustomerBO;
import com.newtouch.bxzs.enterprise.model.vo.CustomerAnalysisVO;
import com.newtouch.bxzs.enterprise.model.vo.CustomerVO;
import com.newtouch.bxzs.enterprise.model.vo.PersonalCustomerVO;
import com.newtouch.bxzs.enterprise.service.PersonalCustomerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 个人客户控制器
 *
 * <p>
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2020/12/22 10:36</td>
 * <td>lingshouyi</td>
 * <td>Create</td>
 * </tr>
 * </table>
 *
 * @author lingshouyi
 * @version 1.0.0
 * @since 1.0.0
 */
@Api(tags = "个人客户管理")
@RestController
@RequestMapping(value = "/personalCustomerController")
@SuppressWarnings("unchecked")
public class PersonalCustomerController {

    @Autowired
    private PersonalCustomerService personalCustomerService;

    /** 静态变量：系统日志 */
    private static final Log logger = LogFactory.getLog(PersonalCustomerController.class);

    @ApiOperation(value = "获取个人客户列表信息", notes = "可按客户名称搜索")
    @PostMapping("/getCustomerList")
    @MyLog(systemFunctionName = "个人客户管理", systemFunctionUrl = "/personalCustomerController/getCustomerList", userOperationType = 4, userOperationSummary = "获取个人客户列表信息")
    public BaseResponse<PersonalCustomerBO> getCustomerList(@RequestBody CustomerVO customerVO) {
        logger.info("获取个人客户列表信息,可按客户名称搜索");
        return RespGenerator.returnOK(personalCustomerService.getCustomerList(customerVO));
    }

    @ApiOperation(value = "根据客户ID获取客户详情")
    @PostMapping("/getPersonalCustomerDetail")
    @MyLog(systemFunctionName = "个人客户管理", systemFunctionUrl = "/personalCustomerController/getPersonalCustomerDetail", userOperationType = 4, userOperationSummary = "根据客户ID获取客户详情")
    public BaseResponse<PersonalCustomerBO> getPersonalCustomerDetail(@RequestBody CustomerVO customerVO) {
        logger.info("根据客户ID获取客户详情");
        return RespGenerator.returnOK(personalCustomerService.getPersonalCustomerDetail(customerVO.getCustomerId()));
    }

    @ApiOperation(value = "增加或者修改个人客户信息")
    @PostMapping("/modifyPersonalCustomer")
    @MyLog(systemFunctionName = "个人客户管理", systemFunctionUrl = "/personalCustomerController/modifyPersonalCustomer", userOperationType = 5, userOperationSummary = "增加或者修改个人客户信息")
    public BaseResponse<PersonalCustomerBO> modifyPersonalCustomer(@RequestBody PersonalCustomerVO personalCustomerVO) {
        return RespGenerator.returnOK(personalCustomerService.modifyPersonalCustomer(personalCustomerVO));
    }

    @ApiOperation(value = "删除/批量删除个人客户信息")
    @PostMapping("/deletePersonalCustomer")
    @MyLog(systemFunctionName = "个人客户管理", systemFunctionUrl = "/personalCustomerController/deletePersonalCustomer", userOperationType = 3, userOperationSummary = "删除/批量删除个人客户信息")
    public BaseResponse<PersonalCustomerBO> deletePersonalCustomer(@RequestBody PersonalCustomerVO personalCustomerVO) {
        logger.info("删除/批量删除个人客户信息");
        return RespGenerator.returnOK(personalCustomerService.deletePersonalCustomer(personalCustomerVO.getCustomerIds()));
    }

    @ApiOperation(value = "查看保险客户分析信息")
    @PostMapping("/getInsuranceCustomerAnalysisInformation")
    @MyLog(systemFunctionName = "个人客户管理", systemFunctionUrl = "/personalCustomerController/getInsuranceCustomerAnalysisInformation", userOperationType = 4, userOperationSummary = "查看保险客户分析信息")
    public BaseResponse<InsuranceCustomerAnalysisBO> getInsuranceCustomerAnalysisInformation(@RequestBody CustomerAnalysisVO customerAnalysisVO) {
        logger.info("查看保险客户分析信息");
        return RespGenerator.returnOK(personalCustomerService.getInsuranceCustomerAnalysisInformation(customerAnalysisVO));
    }

    @ApiOperation(value = "查看银行客户分析信息")
    @PostMapping("/getBankCustomerAnalysisInformation")
    @MyLog(systemFunctionName = "个人客户管理", systemFunctionUrl = "/personalCustomerController/getBankCustomerAnalysisInformation", userOperationType = 4, userOperationSummary = "查看银行客户分析信息")
    public BaseResponse<BankCustomerAnalysisBO> getBankCustomerAnalysisInformation(@RequestBody CustomerAnalysisVO customerAnalysisVO) {
        logger.info("查看银行客户分析信息");
        return RespGenerator.returnOK(personalCustomerService.getBankCustomerAnalysisInformation(customerAnalysisVO));
    }
}
